<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="ec" uri="http://www.extcloud.net"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>欢迎页面</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/layout.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/common.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/management/matter/css/update.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/jquery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/jquery.extcloudSlideMenu.js"></script>
<%@include file="/WEB-INF/view/commonJavascriptVar.jsp"%>
<script type="text/javascript">
$(function() {
	$("li.layout_search_pull_ss a").extcloudSlideMenu({
		init_hideMenu: true ,
		speed: "fast"
	}) ;
});

function deleteItem(matterId,categoryId,aElement) {
	var callback = function(){
		$(aElement).parent().remove();
	};
	ajaxDelete(matterId,categoryId,callback) ;
}
function addItem(matterId,aElement) {
	var callback = function(){
	};
	ajaxAdd(matterId,categoryId,callback) ;
}

function ajaxAdd(matterId,categoryId,callback) {
	var ajaxParams = {} ;
	var url = context + "/management/mmc/ajaxadd/"+categoryId+"_" + matterId ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}

function ajaxDelete(matterId,categoryId,callback) {
	var ajaxParams = {} ;
	var url = context + "/management/mmc/ajaxdelete/"+categoryId+"_" + matterId ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}
</script>
<script type="text/javascript">
function add() {
	Boxy.load('../presearch',{unloadOnHide:true,title:'增加事项'});
}
</script>
</head>
<body>
<div id="layoutAll">
<table cellpadding="0" cellspacing="0" width="100%" id="layout_content">
	<tr>
		<td height="100" valign="top">
		<div id="layout_title">
		<h4>事项修改</h4>
		</div>
		<div id="layout_search">
		<p>&nbsp;</p>
		</div>
		<div id="layout_search_pull">
		<ul>
			<li><a id="backSubmit" href="#"
				onclick="if(confirm('确定修改?')){$('#backForm').submit();}">确定修改</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" />
			<li><a id="backSubmit"
				href="${pageContext.request.contextPath}/management/matter/index">取消并返回列表</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li class="layout_search_pull_ss"><a href="#"><img
				src="${pageContext.request.contextPath}/common/images/menu_up.gif" /></a></li>
		</ul>
		</div>
		</td>
	</tr>
	<tr>
		<td valign="top">
		<div id="layout_content_body">
		<h1 align="center">事项修改</h1>
		<center>
		<form id="backForm"
			action="${pageContext.request.contextPath}/management/matter/update/${matter.matterId}"
			method="post">
		<table align="center" width="90%" border="1px" bordercolor="#D4D4D4"
			cellspacing="0px">
			<tr>
				<td width=100><label for="matterName">审批事项名称</label></td>
				<td><input disabled="disabled" name="matterName" type="text"
					value="${matter.matterName}" /></td>
			</tr>
			<tr>
				<td><label for="matterRequiredData">呈交材料</label></td>
				<td><textarea disabled="disabled" name="matterRequiredData">${matter.matterRequiredData}</textarea></td>
			</tr>
			<tr>
				<td><label for="matterCondition">申办条件</label></td>
				<td><textarea disabled="disabled" name="matterCondition">${matter.matterCondition}</textarea></td>
			</tr>
			<tr>
				<td><label for="attachments">表格下载</label></td>
				<td><c:forEach items="${matter.attachments}"
					var="matterAttachment">
					<div
						id='divAttachment<ec:simpleId id="${matterAttachment.attachmentId}"></ec:simpleId>'>
					<select disabled="disabled" name="attachment">
						<c:forEach items="${attachments}" var="attachment">
							<c:choose>
								<c:when
									test="${matterAttachment.attachmentId==attachment.attachmentId}">
									<option selected="selected" value="${attachment.attachmentId}">${attachment.attachmentName}</option>
								</c:when>
								<c:otherwise>
									<option value="${attachment.attachmentId}">${attachment.attachmentName}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select></div>
				</c:forEach></td>
			</tr>
			<tr>
				<td><label for="matterFlow">申办流程</label></td>
				<td><textarea disabled="disabled" name="matterFlow">${matter.matterFlow }</textarea></td>
			</tr>
			<tr>
				<td><label for="lagels">法律依据</label></td>
				<td><c:forEach items="${matter.legals}" var="matterLegal">
					<select disabled="disabled" name="legal">
						<c:forEach items="${legals}" var="legal">
							<c:choose>
								<c:when test="${matterLegal.legalId==legal.legalId}">
									<option selected="selected" value="${legal.legalId}">${legal.legalName}</option>\
								</c:when>
								<c:otherwise>
									<option value="${legal.legalId}">${legal.legalName}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</c:forEach></td>
			</tr>
			<tr>
				<td><label for="matterType">类型</label></td>
				<td><select name="matterType" disabled="disabled">
					<c:forEach items="${matterTypes}" var="type">
						<c:choose>
							<c:when test="${type==matterType}">
								<option selected="selected" value="${type}">${type}</option>
							</c:when>
							<c:otherwise>
								<option selected="selected" value="${type}">${type}</option>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</select></td>
			</tr>
			<tr>
				<td><label for="matterCharge">收费标准</label></td>
				<td><input disabled="disabled" name="matterCharge" type="text"
					value="${matter.matterCharge}" /></td>
			</tr>
			<tr>
				<td><label for="matterTimeLimit">时限</label></td>
				<td><input disabled="disabled" name="matterTimeLimit"
					type="text" value="${matter.matterTimeLimit}" /></td>
			</tr>
			<tr>
				<td><label for="handleUnit">申办地点</label></td>
				<td><select disabled="disabled" name="handleUnit">
					<c:forEach items="${handleUnits}" var="handleUnit">
						<c:choose>
							<c:when
								test="${handleUnit.handleUnitId==matter.handleUnit.handleUnitId}">
								<option selected value="${handleUnit.handleUnitId}">${handleUnit.handleUnitName}</option>
							</c:when>
							<c:otherwise>
								<option value="${handleUnit.handleUnitId}">${handleUnit.handleUnitName}</option>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</select></td>
			</tr>
			<tr>
				<td><label for="matterKeywords">关键字</label></td>
				<td><input id="matterKeywords" name="matterKeywords"
					value="${matter.matterKeywords}" /></td>
			</tr>
			<tr>
				<td>分类信息</td>
				<td>
				<div id="categoriesDiv"><c:forEach
					items="${superMatterCategoryChains}" var="superMatterCategoryChain">
					<div><c:forEach items="${superMatterCategoryChain}"
						var="tempMatterCategory" varStatus="index">
						<span>${tempMatterCategory.categoryName}</span>
						<c:choose>
							<c:when
								test="${index.index != fn:length(superMatterCategoryChain)-1}">
								<span>&gt;</span>
							</c:when>
							<c:otherwise>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
									href="javascript:void(0);"
									onclick="javascript:deleteItem('${matter.matterId}','${tempMatterCategory.categoryId}',this);">删除</a>
							</c:otherwise>
						</c:choose>
					</c:forEach>&nbsp;&nbsp;&nbsp;&nbsp;</div>
				</c:forEach></div>
				<a
					onclick="javascript:addItem('${matter.matterId}',$('#categoriesDiv'));"></a>
				</td>
			</tr>
		</table>
		</form>
		</center>
		</div>
		</td>
	</tr>
</table>
</div>
</body>
</html>